package com.example.nophase.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.nophase.R;
import com.example.nophase.entity.AreaListDto;

import java.util.List;

public class AreaListAdapter extends BaseAdapter {
    List<AreaListDto> list;
    Context context;

    public AreaListAdapter(List<AreaListDto> list, Context context) {
        this.list = list;
        this.context = context;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = LayoutInflater.from(context).inflate(R.layout.area_list_item,null);
        TextView textView = view.findViewById(R.id.name);
        textView.setText(list.get(position).getName());
        return view;
    }
}
